package org.example;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyProxyHandler implements InvocationHandler {

    private final Object realObject;

    public MyProxyHandler(Object realObject) {
        this.realObject = realObject;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println("Before method: " + method.getName());


        Object result = method.invoke(realObject, args);


        System.out.println("After method: " + method.getName());

        return result;
    }
}
